<template>
  <!-- 操作日志详细 -->
  <el-dialog title="操作日志详细" :visible.sync="visible" width="700px" append-to-body @closed="reset">
    <el-form ref="form" :model="form" label-width="100px" size="mini">
      <el-row>
        <el-col :span="12">
          <el-form-item label="操作模块：">{{ form.title }} / {{ typeFormat(form) }}</el-form-item>
          <el-form-item label="登录信息：">{{ form.operatorName }} / {{ form.operatorIp }} </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="请求方式：">{{ form.requestMethod }}</el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="执行方法：">{{ form.method }}</el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="请求地址：">{{ form.operatorUrl }}</el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="请求参数：">{{ form.requestParam }}</el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="返回参数：">{{ form.jsonResult }}</el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="操作状态：">
            <div v-if="form.status === '0'">正常</div>
            <div v-else-if="form.status === '1'">失败</div>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="操作时间：">{{ form.operateTime }}</el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="异常信息：" v-if="form.status === '1'">{{ form.errorMsg }}</el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="close">关 闭</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { getInfo } from "@/api/system/logs/operate";

export default {
  name: "detail",
  props: {
    typeOptions: {
      type: Array,
      default: []
    }
  },
  data() {
    return {
      id: undefined,
      visible: false,
      form: {
        title: undefined,
        businessType: undefined,
        method: undefined,
        requestMethod: undefined,
        operatorType: undefined,
        operatorName: undefined,
        operatorUrl: undefined,
        operatorIp: undefined,
        operatorLocation: undefined,
        requestParam: undefined,
        jsonResult: undefined,
        status: undefined,
        errorMsg: undefined,
        operateTime: undefined
      }
    }
  },
  methods: {
    init(id) {
      this.visible = true;
      this.id = id;
      if (id) {
        this.initData();
      }
    },
    initData() {
      getInfo(this.id).then(response => {
        this.form = response;
      });
    },
    close() {
      this.visible = false;
    },
    // 表单重置
    reset() {
      this.id = undefined;
      this.form = {
        title: undefined,
        businessType: undefined,
        method: undefined,
        requestMethod: undefined,
        operatorType: undefined,
        operatorName: undefined,
        operatorUrl: undefined,
        operatorIp: undefined,
        operatorLocation: undefined,
        requestParam: undefined,
        jsonResult: undefined,
        status: undefined,
        errorMsg: undefined,
        operateTime: undefined
      };
    },
    // 操作日志类型字典翻译
    typeFormat(row, column) {
      return this.selectDictLabel(this.typeOptions, row.businessType);
    }
  }
}
</script>

<style scoped>

</style>
